package com.xrd.uart.uart;


import com.xrd.uart.interaction.BaseReaderHelper;

import java.util.Observer;

/**
 * Creatd by Yumiko
 * All is boring expect MeiZi.
 * on 2019/11/28
 */
public class TtyS0ReaderHelper extends BaseReaderHelper {
    private static TtyS0ReaderHelper mTtyS0ReaderHelper = null;
    private static final Integer LOCK = new Integer(0);

    private TtyS0ReaderHelper(){

    }

    public static TtyS0ReaderHelper getDefaultHelper() {
        if (mTtyS0ReaderHelper == null) {
            synchronized(LOCK) {
                if (mTtyS0ReaderHelper == null) {
                    mTtyS0ReaderHelper = new TtyS0ReaderHelper();
                }
            }
        }
        return mTtyS0ReaderHelper;
    }

    public void registerObserver(Observer observer) {
        if (this.mReader != null) {
            this.mReader.registerObserver(observer);
        } else {
            throw new NullPointerException("Please build the connection first!");
        }
    }

    public void unRegisterObserver(Observer observer) {
        if (this.mReader != null) {
            this.mReader.unRegisterObserver(observer);
        } else {
            throw new NullPointerException("Please build the connection first!");
        }
    }


}
